<?php
/**
 * 后台店铺Store管理路由
 * Author: lyun
 * Date: 2018/3/27
 * Created by Panxsoft.
 */
use Illuminate\Support\Facades\Route;

Route::group([
    'prefix'=>'/store',
    'namespace'=>'Admin\Store',
    'middleware'=>'StoreAuth'
], function() {
    /**
     * 首页面板
     *
     * @see \App\Http\Controllers\Admin\Store\DashboardController::index
     */
    Route::get('/dashboard', 'DashboardController@index')
        ->name(\App\Http\Controllers\Admin\Store\DashboardController::ROUTES['index']);

    /**
     * @deprecated
     * 访客统计数据
     *
     * @see \App\Http\Controllers\Admin\Store\DashboardController::getvisitCounts()
     */
    Route::get('/get-visit-counts', 'DashboardController@getvisitCounts');

    /**
     * 店铺下各个设备的测肤统计数据
     *
     * @see \App\Http\Controllers\Admin\Store\DashboardController::getStoreDeviceAccountSkinCounts()
     */
    Route::get('/get-skin-counts', 'DashboardController@getStoreDeviceAccountSkinCounts')
        ->name(\App\Http\Controllers\Admin\Store\DashboardController::ROUTES['device-counts']);

    /**
     * 当前店铺的测肤统计数据
     *
     * @see \App\Http\Controllers\Admin\Store\DashboardController::getStoreSkinCounts()
     */
    Route::get('/get-store-skin-counts', 'DashboardController@getStoreSkinCounts')
        ->name(\App\Http\Controllers\Admin\Store\DashboardController::ROUTES['skin-counts']);

    /**
     *  后台店铺职员的管理
     *
     * @see \App\Http\Controllers\Admin\Store\StoreStaffController
     */
    Route::resource('/staff', 'StoreStaffController')
        ->names(\App\Http\Controllers\Admin\Store\StoreStaffController::ROUTES);

    /**
     * 导出店铺微信用户
     *
     * @see \App\Http\Controllers\Admin\Store\WechatUserController::exportStoreUser()
     */
    Route::get('/export-store-user', 'WechatUserController@exportStoreUser');

    /**
     * 测肤微信用户信息和肤质检测统计数据
     *
     * @see \App\Http\Controllers\Admin\Store\WechatUserController::showWithSkinRecordInfo()
     */
    Route::get('/wechat-user/show-with-skin-record-info', 'WechatUserController@showWithSkinRecordInfo')
        ->name(\App\Http\Controllers\Admin\Store\WechatUserController::ROUTES['showWithSkinRecordInfo']);

    /**
     * 查看所有微信用户
     *
     * @see \App\Http\Controllers\Admin\Store\WechatUserController
     */
    Route::resource('/wechat-user', 'WechatUserController')
        ->names(\App\Http\Controllers\Admin\Store\WechatUserController::ROUTES);

    /**
     *  后台店铺职员启用和禁用切换
     *
     * @see \App\Http\Controllers\Admin\Store\StoreStaffController::patchEnabled()
     */
    Route::patch('/staff-status/{staff_id}', 'StoreStaffController@patchEnabled')
        ->name(\App\Http\Controllers\Admin\Store\StoreStaffController::ROUTES['patch']);

    /**
     *  后台店铺职员绑定二维码
     *
     * @see \App\Http\Controllers\Admin\Store\StoreStaffController::bindQrCode()
     */
    Route::get('/staff-bind-qrcode/{staff_id}', 'StoreStaffController@bindQrCode')
        ->name(\App\Http\Controllers\Admin\Store\StoreStaffController::ROUTES['bind']);

    /**
     * 后台店铺职员解除绑定二维码
     *
     * @see \App\Http\Controllers\Admin\Store\StoreStaffController::patchUnbindWechat()
     */
    Route::patch('/staff-unbind-wechat/{staff_id}', 'StoreStaffController@patchUnbindWechat')
        ->name(\App\Http\Controllers\Admin\Store\StoreStaffController::ROUTES['unbind']);

    /**
     *  后台店铺设备账号的管理
     *
     * @see \App\Http\Controllers\Admin\Store\DeviceAccountController
     */
    Route::resource('/device-account', 'DeviceAccountController')
        ->names(\App\Http\Controllers\Admin\Store\DeviceAccountController::ROUTES);

    /**
     * 启动或停用账号
     *
     * @see \App\Http\Controllers\Admin\Store\DeviceAccountController::patchEnabled()
     */
    Route::patch('/device-account-enabled/{account_id}', 'DeviceAccountController@patchEnabled')
        ->name(\App\Http\Controllers\Admin\Store\DeviceAccountController::ROUTES['patch']);

    /**
     * 整体妆容管理
     *
     * @see \App\Http\Controllers\Admin\Store\PackController
     */
    Route::resource('/pack', 'PackController')
        ->names(\App\Http\Controllers\Admin\Store\PackController::ROUTES);

    /**
     * 订单管理
     *
     * @see \App\Http\Controllers\Admin\Store\OrderController
     */
    Route::resource('/order', 'OrderController',['only' => ['index', 'show']])
        ->names(\App\Http\Controllers\Admin\Store\OrderController::ROUTES);

    /**
     * 同步有赞的订单
     *
     * @see \App\Http\Controllers\Admin\Store\OrderController::syncOrders()
     */
    Route::post('/order', 'OrderController@syncOrders');

    /**
     *  店铺后台商品管理
     */
    Route::group(['namespace'=>'Product'], function(){

        // 后台代理Customer的商品管理
        /**
         *  添加商品时，请求product_model数据 或 category数据
         *
         * @see \App\Http\Controllers\Admin\Store\Product\ProductController::createInfo()
         */
        Route::get('/product/create-info', 'ProductController@createInfo');

        /**
         * 自定义修改商品的 [type => value] 信息
         *
         * product/patch-status => product-status
         *
         * @see \App\Http\Controllers\Admin\Store\Product\ProductController::patchStatus()
         */
        Route::patch('/product-status', 'ProductController@patchStatus')
            ->name(\App\Http\Controllers\Admin\Store\Product\ProductController::ROUTES['patchStatus']);


        /**
         * 更新 store_pivot_customer_product 优先级， 与上下架操作
         * @see \App\Http\Controllers\Admin\Store\Product\ProductController::updateStorePivotCustomerProduct()
         */
        Route::patch('/update_store_pivot_customer_product', 'ProductController@updateStorePivotCustomerProduct')
            ->name(\App\Http\Controllers\Admin\Store\Product\ProductController::ROUTES['updateStorePivotCustomer']);

        /**
         * 导出店铺商品
         *
         * @see \App\Http\Controllers\Admin\Store\Product\ProductController::exportStoreProduct()
         */
        Route::get('/export-store-product', 'ProductController@exportStoreProduct');

        /**
         * 商品的管理
         *
         * @see \App\Http\Controllers\Admin\Store\Product\ProductController
         */
        Route::resource('/product', 'ProductController')
            ->names(\App\Http\Controllers\Admin\Store\Product\ProductController::ROUTES);

        /**
         * 有赞商品的管理
         * @see \App\Http\Controllers\Admin\Store\Product\YouzanProductController::syncItemsOnSale()
         */
        Route::post('/youzan/sync_on_sale_product', 'YouzanProductController@syncItemsOnSale')
            ->name('admin.store.sync_on_sale_product');

        /**
         * 有赞商品的管理
         * @see \App\Http\Controllers\Admin\Store\Product\YouzanProductController::syncItemsInventory()
         */
        Route::post('/youzan/sync_inventory_product', 'YouzanProductController@syncItemsInventory')
            ->name('admin.store.sync_inventory_product');

        /**
         * 删除商品关联的图片
         *
         * @see \App\Http\Controllers\Admin\Store\Product\ProductImageController::destroy()
         */
        Route::delete('/product-image/{prod_img_id}', 'ProductImageController@destroy');

        // 后台虚拟仓和商品的管理
        /**
         *  虚拟仓商品的开启和关闭
         *
         * @see \App\Http\Controllers\Admin\Store\Product\VirtualProductController::openVirtualProduct()
         */
        Route::post('/virtual-status', 'VirtualProductController@openVirtualProduct');

        /**
         *  虚拟商品的管理
         *
         * @see \App\Http\Controllers\Admin\Store\Product\VirtualProductController
         */
        Route::resource('/virtual-product', 'VirtualProductController');

    });

    /**
     * 肤质检测的统计数据
     *
     * @see \App\Http\Controllers\Admin\Store\SkinRecordController::indexUsageCount()
     */
    Route::get('/skin-record/index-usage-count', 'SkinRecordController@indexUsageCount')
        ->name(\App\Http\Controllers\Admin\Store\SkinRecordController::ROUTES['indexUsageCount']);

    /**
     * 会美、唯丝普测肤数据统计饼图
     *
     * @see \App\Http\Controllers\Admin\Store\SkinRecordController::showPieChartData()
     */
    Route::get('/skin-record/pie-chart-data', 'SkinRecordController@showPieChartData')
        ->name(\App\Http\Controllers\Admin\Store\SkinRecordController::ROUTES['showPieChartData']);

    /**
     * 肤质检测数据的展示
     *
     * @see \App\Http\Controllers\Admin\Store\SkinRecordController
     */
    Route::resource('/skin-record', 'SkinRecordController')
        ->names(\App\Http\Controllers\Admin\Store\SkinRecordController::ROUTES);

    /**
     * 肤质检测数据的展示(详情)
     *
     * @see \App\Http\Controllers\Admin\Store\SkinRecordController::skinRecordList
     */
    Route::get('skin-record-list', 'SkinRecordController@skinRecordList')
        ->name(\App\Http\Controllers\Admin\Store\SkinRecordController::ROUTES['list']);

    /**
     * wax测肤分数关联商品列表
     * @see \App\Http\Controllers\Admin\Store\RecommendProductController::waxIndex()
     */
    Route::get('wax-recommend-product', 'RecommendProductController@waxIndex')
        ->name(\App\Http\Controllers\Admin\Store\RecommendProductController::ROUTES['waxIndex']);

    /**
     * hm测肤分数关联商品列表
     * @see \App\Http\Controllers\Admin\Store\RecommendProductController::hmIndex()
     */
    Route::get('hm-recommend-product', 'RecommendProductController@hmIndex')
        ->name(\App\Http\Controllers\Admin\Store\RecommendProductController::ROUTES['hmIndex']);

    /**
     * 新增单个wax/hm测肤分数关联商品
     * @see \App\Http\Controllers\Admin\Store\RecommendProductController::singleStore()
     */
    Route::post('single-recommend-product', 'RecommendProductController@singleStore')
        ->name(\App\Http\Controllers\Admin\Store\RecommendProductController::ROUTES['singleStore']);

    /**
     * hm，wax测肤分数关联商品
     * @see \App\Http\Controllers\Admin\Store\RecommendProductController
     */
    Route::resource('recommend-product', 'RecommendProductController')
        ->names(\App\Http\Controllers\Admin\Store\RecommendProductController::ROUTES);
});

Route::group([
    'prefix'     => '/store',
    'namespace'  => 'Youzan',
    'middleware' => 'StoreAuth'
], function () {
    /**
     * 有赞店铺授权信息管理
     *
     * @see \App\Http\Controllers\Youzan\YouzanShopController::show()
     */
    Route::get('/youzan-shop', 'YouzanShopController@show');
});
